home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / gcc / fd2inline.LHA / fd2inline / bin / auto next >
Text File  |  1992-03-20  |  2KB  |  64 lines

  1. # copyright by Wolfgang Baron, freely distributable
  2. # state: 0==ignore, 1==synopsis, 2==registers, 3== empty before proto, 4==proto
  3. # had: encountered protos
  4. BEGIN        { state=0; obraces= 0; if ("" == stderr) stderr="/dev/stderr" }
  5. /SYNOPSIS/  { state=1; obraces=0; had=0; maybe= ""; next }
  6. /FUNCTION/  { state=0;
  7.           if (obraces != 0)
  8.         print "unbalanced braces in line " FNR >stderr;
  9.           else if ( 0==had )
  10.         print "maybe " maybe ;
  11.           next
  12.         }
  13. state==1 &&
  14. 0<NF        { opennow= gsub( "\(", "(" );
  15.           closenow= gsub( "\)", ")" );
  16.           obraces+= opennow - closenow;
  17.           if (!opennow && !closenow) {
  18.         if (0<had) {
  19.           print "ignore 0<had in line " FNR >stderr;
  20.           state= 0;
  21.         }
  22.         else print "continue synopis in line " FNR >stderr;
  23.           }
  24.           else {
  25. #         print "1->2 " FNR ": " $0 >stderr;
  26.         state= 2 }
  27.           if (0>obraces) {
  28.         print "synopsis has too many ')' in line " FNR >stderr;
  29.         state= 0; }
  30.           maybe= $0;
  31.           next
  32.         }
  33. state==2    { if (0==NF) {
  34.         print "warning: registers expected in line " FNR >stderr;
  35.         state= 1 }
  36.           else if (0==obraces) state= 3;
  37.           else {
  38. #         print "2->1 in line " FNR >stderr;
  39.         state= 1; }
  40.           next }
  41. state==3    { if (0<NF)
  42.         print "warning: empty line " FNR " expected." >stderr;
  43.           else state= 4;
  44.           next
  45.         }
  46. state==4 &&
  47. 0<NF        { opennow= gsub( "\(", "(" );
  48.           closenow= gsub( "\)", ")" );
  49.           obraces+= opennow - closenow;
  50.           gsub( "^t*", "" );
  51.           gsub( "^ *", "" );
  52.           gsub( " *$", "" );
  53.           print $0;
  54.           if ((opennow || closenow) && 0==obraces) {
  55. #         print "4->1 " FNR ": " $0 >stderr;
  56.         state=1; }
  57.           if (0>obraces) {
  58.         print "proto has too many ')' in line " FNR >stderr;
  59.         state=0;
  60.           }
  61.           had++;
  62.         }
  63. END        { print "" }
  64.